package com.youtills.domain.contact;

import com.youtills.resource.BaseResource;
import com.youtills.resource.CommonAttribute;
import com.youtills.resource.Resource;
import com.youtills.resource.ResourceAttributeValue;
import com.youtills.resource.ResourceRelationship;

/**
 * TODO - !!!doc me!!!
 *
 * @author ravi.chiluveru
 * @since 23.0 (10/4/14)
 */
public class Address extends BaseResource {

    public static final long RT_ADDRESS = 101;
    public static final long RL_ADDRESS__RESOURCE = 101;

    public static Address NULL_ADDRESS = new Address();

    private final ResourceAttributeValue<String> address1;
    private final ResourceAttributeValue<String> address2;
    private final ResourceAttributeValue<String> city;
    private final ResourceAttributeValue<String> state;
    private final ResourceAttributeValue<String> country;
    private final ResourceAttributeValue<String> zip;
    private final ResourceRelationship<Resource, Address> resourceAdresses;

    public void addResourceId(long resourceType, long resourceId) {
        resourceAdresses.addTargetResourceId(resourceType, resourceId, null);
    }

    public Address() {
        super();

        this.address1 = new ResourceAttributeValue<String>(this, CommonAttribute.address_1);
        this.address2 = new ResourceAttributeValue<String>(this, CommonAttribute.address_2);
        this.city = new ResourceAttributeValue<String>(this, CommonAttribute.city);
        this.state = new ResourceAttributeValue<String>(this, CommonAttribute.state);
        this.country = new ResourceAttributeValue<String>(this, CommonAttribute.country);
        this.zip = new ResourceAttributeValue<String>(this, CommonAttribute.zip);

        resourceAdresses = new ResourceRelationship<>(ResourceRelationship.SourceLocation.right, null, this, CommonAttribute.resource_project);

    }

    @Override
    protected String getTableName() {
        return "res_contact__address";
    }

    @Override
    protected String getResourceIdColumn() {
        return "address_id";
    }

    public Long getAddressId() {
        return getResourceId();
    }

    public String getAddress1() {
        return address1.getValue();
    }

    public void setAddress1(String address1) {
        this.address1.setValue(address1);
    }

    public String getAddress2() {
        return address2.getValue();
    }

    public void setAddress2(String address2) {
        this.address2.setValue(address2);
    }

    public String getCity() {
        return city.getValue();
    }

    public void setCity(String city) {
        this.city.setValue(city);
    }

    public String getState() {
        return state.getValue();
    }

    public void setState(String state) {
        this.state.setValue(state);
    }

    public String getCountry() {
        return country.getValue();
    }

    public void setCountry(String country) {
        this.country.setValue(country);
    }

    public String getZip() {
        return zip.getValue();
    }

    public void setZip(String zip) {
        this.zip.setValue(zip);
    }
}
